package GUI;

import java.awt.Container;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList;

import javax.swing.*;

import Animalmanagement.AnimalManagement;
import Event.Calendar;
import Event.EventCalendar;
import Quiz.QuizSetting;
import Signup.AccountManagement;

public class Main implements MouseListener {

	protected static final int DISPOSE_ON_CLOSE = 0;
	protected static final int EXIT_ON_CLOSE = 0;
	JFrame mainframe = new JFrame();
	ImageIcon main = new ImageIcon("src/source/main/main.png");
	JButton btn1, btn2, btn3, btn4, btn5;
	ImageIcon icon1, icon2, icon3, icon4, icon5;
	JLabel l1 = new JLabel();
	JLabel l2 = new JLabel();
	JLabel l3 = new JLabel();
	JLabel l4 = new JLabel();
	JLabel l5 = new JLabel();

	AnimalManagement aniManage = AnimalManagement.getInstance();

	EventCalendar ec = new EventCalendar(aniManage);
	Reservation rv = new Reservation();
	Zoomap zoo = new Zoomap(aniManage);
	SignUp signup = new SignUp();
	QuizSetting frame = new QuizSetting(aniManage);

	JPanel background = new JPanel() {
		public void paintComponent(Graphics g) {
			g.drawImage(main.getImage(), 0, 0, null);
			setOpaque(false);
		}
	};

	public Main() {
		mainframe.add(background);
		background.setLayout(null);

		btn1 = new JButton(new ImageIcon("src/source/main/list1.jpg"));
		btn2 = new JButton(new ImageIcon(("src/source/main/list2.jpg")));
		btn3 = new JButton(new ImageIcon(("src/source/main/list3.jpg")));
		btn4 = new JButton(new ImageIcon(("src/source/main/list4.jpg")));
		btn5 = new JButton(new ImageIcon(("src/source/main/list5.jpg")));

		icon1 = new ImageIcon(("src/source/main/btn1.jpg"));
		icon2 = new ImageIcon(("src/source/main/btn2.jpg"));
		icon3 = new ImageIcon(("src/source/main/btn3.jpg"));
		icon5 = new ImageIcon(("src/source/main/btn4.jpg"));
		icon4 = new ImageIcon(("src/source/main/btn5.jpg"));

		background.add(btn1);
		background.add(btn2);
		background.add(btn3);
		background.add(btn4);
		background.add(btn5);

		background.add(l1);
		l1.setBounds(40, 640, 196, 41);

		background.add(l2);
		l2.setBounds(220, 450, 270, 43);

		background.add(l3);
		l3.setBounds(390, 450, 197, 43);

		background.add(l4);
		l4.setBounds(510, 440, 210, 43);

		background.add(l5);
		l5.setBounds(770, 350, 197, 43);

		btn1.setBounds(50, 340, 167, 282);
		btn2.setBounds(240, 250, 163, 178);
		btn3.setBounds(350, 510, 224, 141);
		btn4.setBounds(470, 260, 303, 145);
		btn5.setBounds(740, 420, 156, 237);

		btn1.addMouseListener(this);
		btn2.addMouseListener(this);
		btn3.addMouseListener(this);
		btn4.addMouseListener(this);
		btn5.addMouseListener(this);

		btn1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {

				mainframe = ec;
				ec.setVisible(true);
				ec.setLocationRelativeTo(null);

			}
		});

		btn2.addActionListener(new ActionListener() {

			public void actionPerformed(ActionEvent arg0) {
				mainframe = rv;
				mainframe.setVisible(true);
				mainframe.setLocationRelativeTo(null);
			}

		});

		btn3.addActionListener(new ActionListener() {

			public void actionPerformed(ActionEvent arg0) {
				try {
					mainframe = zoo;
					zoo.setSize(1020, 770);
					mainframe.setVisible(true);
					mainframe.setLocationRelativeTo(null);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});

		btn4.addActionListener(new ActionListener() {

			public void actionPerformed(ActionEvent arg0) {
				mainframe = signup;
				signup.setVisible(true);
			}

		});

		btn5.addActionListener(new ActionListener() {

			public void actionPerformed(ActionEvent arg0) {
				try {
					mainframe = frame;
					frame.setSize(975, 770);
					frame.setVisible(true);
					frame.setLocationRelativeTo(null);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});

		btn1.setBorderPainted(false);
		btn2.setBorderPainted(false);
		btn3.setBorderPainted(false);
		btn4.setBorderPainted(false);
		btn5.setBorderPainted(false);
		mainframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		mainframe.setSize(975, 770);
		mainframe.setVisible(true);

	}

	public static void main(String[] args) {
		Main test = new Main();
		test.mainframe.setLocationRelativeTo(null);
	}

	public void mouseClicked(MouseEvent arg0) {
	}

	public void mouseEntered(MouseEvent me) {
		if (me.getSource() == btn1) {
			l1.setVisible(true);
			l1.setIcon(icon1);
		} else if (me.getSource() == btn2) {
			l2.setVisible(true);
			l2.setIcon(icon2);
		} else if (me.getSource() == btn3) {
			l3.setVisible(true);
			l3.setIcon(icon3);
		} else if (me.getSource() == btn4) {
			l4.setVisible(true);
			l4.setIcon(icon4);
		} else if (me.getSource() == btn5) {
			l5.setVisible(true);
			l5.setIcon(icon5);
		}

	}

	public void mouseExited(MouseEvent me) {
		if (me.getSource() == btn1) {
			l1.setVisible(false);
		} else if (me.getSource() == btn2) {
			l2.setVisible(false);
		} else if (me.getSource() == btn3) {
			l3.setVisible(false);
		} else if (me.getSource() == btn4) {
			l4.setVisible(false);
		} else if (me.getSource() == btn5) {
			l5.setVisible(false);
		}
	}

	public void mousePressed(MouseEvent arg0) {
	}
	public void mouseReleased(MouseEvent arg0) {
	}

}
